using System;
using System.Collections.Generic;

namespace Jonathan.Classes
{
   /// <summary>
   /// Class used to parse bible and other texts passages.
   /// </summary>
   public class Parser
   {
      /// <summary>
      /// Parses the given scripture reference...
      /// </summary>
      /// <param name="scripture">scripture reference.</param>
      /// <returns>List of Passages.</returns>
      public static List<CPassage> Parse (string scripture)
      {
         /*
         Gen 1 # first chapter of Genesis
         Genesis 1 # Full names supported
         1 Kgs 1 - 2 # 1st and 2nd chapter in 1 Kings
         Luke 15:8-10 # Specific verses from chapters supported
         Luke 15:1-7, 11-32 # Multiple, disjoint verse specification
         Matt 9:12; Mark 2:17; Luke 5: 31 # Multiple books together
         Gen 1, 3 # discontinuous chapters
         Gen 1 - 2:3 # Span chapters, to a specific verse
         */

         List<CPassage> passageList = new List<CPassage> ();

         // Check for empty string...
         if (string.IsNullOrEmpty (scripture))
            return passageList;

         string scrip = scripture.Replace (" ", "");
         int len = scrip.Length;
         bool bBook = true;
         bool bChap = false;
         bool bVerse = false;
         string book = "";
         string chap = "";
         string verse = "";

         int a = 0;
         if (Char.IsDigit (scrip[0])) { book += scrip[0].ToString (); a++; }
         for (; a < len; a++)
         {
            char c = scrip[a];
            if (c == ':')
            {
               bBook = false;
               bChap = false;
               bVerse = true;
            }
            else if (c == ',')
            {
               bool handled = false;
               if (bBook)
               {
                  // We may have a comma in a book name...
                  if ((a + 1) < len)
                  {
                     if (Char.IsLetter (scrip[a + 1]))
                     {
                        book += c;
                        handled = true;
                     }
                  }
               }
               if (!handled)
               {
                  AddPassage (passageList, book, chap, verse);
                  if (string.IsNullOrEmpty (verse))
                     chap = "";
                  verse = "";
               }
            }
            else if (c == ';')
            {
               AddPassage (passageList, book, chap, verse);
               book = "";
               chap = "";
               verse = "";
               bBook = true;
               bChap = false;
               bVerse = false;
            }
            else if (c == '.')
            {
               if (bBook)
               {
                  bBook = false;
                  bChap = true;
               }
               else
               {
                  bChap = false;
                  bVerse = true;
               }
            }
            else if (c == '-')
            {
               if (bChap)
                  chap += c;
               if (bVerse)
                  verse += c;
            }
            else if (Char.IsDigit (c))
            {
               if (bBook)
               {
                  if ((a + 1) < len && /*!*/Char.IsLetter/*.IsDigit*/(scrip[a + 1]) && string.IsNullOrEmpty (book))
                  {
                     book += c;
                  }
                  else
                  {
                     bBook = false;
                     bChap = true;
                  }
               }
               if (bChap)
                  chap += c;
               else if (!bBook)
                  verse += c;
            }
            else if (!Char.IsLetter (c))
            {
            }
            else if (bBook)
               book += c;
         }
         AddPassage (passageList, book, chap, verse);


         return passageList;
      }

      /// <summary>
      /// Adds a passage to the passage list.
      /// </summary>
      /// <param name="passageList">List to add passage to.</param>
      /// <param name="book">Book for passage.</param>
      /// <param name="chap">Chapter for passage.</param>
      /// <param name="verse">Verse for passage.</param>
      private static void AddPassage (List<CPassage> passageList, string book, string chap, string verse)
      {
         if ((!string.IsNullOrEmpty (book) || !string.IsNullOrEmpty (verse)) && !string.IsNullOrEmpty (chap))
         {
            if (string.IsNullOrEmpty (book))
            {
               if (passageList.Count > 0)
               {
                  book = passageList[passageList.Count - 1].Book;
               }
               else
               {
                  // We don't know what book it is...
                  return;
               }
            }

            string b = GetBook (book, true);
            if (string.IsNullOrEmpty (b))
            {
               if (string.IsNullOrEmpty (b)) return;
            }

            string v = string.IsNullOrEmpty (verse) ? null : verse;


            if (v != null && v.IndexOf ("-") != -1)
            {
               int start = Convert.ToInt32 (v.Split ('-')[0].Trim ());
               int end = Convert.ToInt32 (v.Split ('-')[1].Trim ());
               for (int a = start; a <= end; a++)
               {
                  passageList.Add (new CPassage (b, chap, a.ToString ()));
               }
            }
            else if (chap.IndexOf ("-") != -1)
            {
               int start = Convert.ToInt32 (chap.Split ('-')[0].Trim ());
               int end = Convert.ToInt32 (chap.Split ('-')[1].Trim ());
               for (int a = start; a <= end; a++)
               {
                  if (v != null && a == end)
                  {
                     for (int c = 1; c <= Convert.ToInt32 (v); c++)
                     {
                        passageList.Add (new CPassage (b, a.ToString (), c.ToString ()));
                     }
                  }
                  else
                  {
                     passageList.Add (new CPassage (b, a.ToString (), null));
                  }
               }
            }
            else
            {
               passageList.Add (new CPassage (b, chap, v));
            }
         }
      }

      /// <summary>
      /// Gets the name of the book for the give string...
      /// </summary>
      /// <param name="book">Book String.</param>
      /// <param name="fullName">True if you want the full name, false if you want the abbrevation.</param>
      /// <returns>Name or Abbreviation of Book</returns>
      public static string GetBook (string book, bool fullName)
      {
         string b = book.ToLower ().Replace (" ", "");
         if (string.IsNullOrEmpty (b))
         {
            return null;
         }
         if (b.Equals ("genesis") || b.Equals ("gen") || b.Equals ("ge") || b.Equals ("gn"))
         {
            return (fullName) ? "Genesis" : "Gen";
         }
         if (b.Equals ("exodus") || b.Equals ("exo") || b.Equals ("ex") || b.Equals ("exod"))
         {
            return (fullName) ? "Exodus" : "Exo";
         }
         if (b.Equals ("leviticus") || b.Equals ("lev") || b.Equals ("le") || b.Equals ("lv"))
         {
            return (fullName) ? "Leviticus" : "Lev";
         }
         if (b.Equals ("numbers") || b.Equals ("num") || b.Equals ("nu") || b.Equals ("nm") || b.Equals ("nb"))
         {
            return (fullName) ? "Numbers" : "Num";
         }
         if (b.Equals ("deuteronomy") || b.Equals ("deut") || b.Equals ("dt") || b.Equals ("deu") || b.Equals ("de"))
         {
            return (fullName) ? "Deuteronomy" : "Deu";
         }
         if (b.Equals ("joshua") || b.Equals ("josh") || b.Equals ("jos") || b.Equals ("jsh"))
         {
            return (fullName) ? "Joshua" : "Jos";
         }
         if (b.Equals ("judges") || b.Equals ("judg") || b.Equals ("jdg") || b.Equals ("jg") || b.Equals ("jdgs"))
         {
            return (fullName) ? "Judges" : "Jdg";
         }
         if (b.Equals ("ruth") || b.Equals ("rth") || b.Equals ("ru") || b.Equals ("rut"))
         {
            return "Ruth";
         }
         if (b.Equals ("1samuel") || b.Equals ("1sam") || b.Equals ("1sa") || b.Equals ("1s") || b.Equals ("1sm") || b.Equals ("isam") || b.Equals ("isamuel") || b.Equals ("1stsamuel") || b.Equals ("firstsamuel"))
         {
            return (fullName) ? "1 Samuel" : "1Sam";
         }
         if (b.Equals ("2samuel") || b.Equals ("2sam") || b.Equals ("2sa") || b.Equals ("2s") || b.Equals ("iisa") || b.Equals ("2sm") || b.Equals ("iisam") || b.Equals ("iisamuel") || b.Equals ("2ndsamuel") || b.Equals ("secondsamuel"))
         {
            return (fullName) ? "2 Samuel" : "2Sam";
         }
         if (b.Equals ("1kings") || b.Equals ("1kgs") || b.Equals ("1kg") || b.Equals ("1ki") || b.Equals ("1k") || b.Equals ("ikgs") || b.Equals ("iki") || b.Equals ("ikings") || b.Equals ("1stkgs") || b.Equals ("1stkings") || b.Equals ("firstkings") || b.Equals ("firstkgs") || b.Equals ("1kin"))
         {
            return (fullName) ? "1 Kings" : "1Ki";
         }
         if (b.Equals ("2kings") || b.Equals ("2kgs") || b.Equals ("2kg") || b.Equals ("2ki") || b.Equals ("2k") || b.Equals ("iikgs") || b.Equals ("iiki") || b.Equals ("iikings") || b.Equals ("2ndkgs") || b.Equals ("2ndkings") || b.Equals ("secondkings") || b.Equals ("secondkgs") || b.Equals ("2kin"))
         {
            return (fullName) ? "2 Kings" : "2Ki";
         }
         if (b.Equals ("1chronicles") || b.Equals ("1chron") || b.Equals ("1ch") || b.Equals ("ich") || b.Equals ("1chr") || b.Equals ("ichr") || b.Equals ("ichron") || b.Equals ("ichronicles") || b.Equals ("1stchronicles") || b.Equals ("firstchronicles"))
         {
            return (fullName) ? "1 Chronicles" : "1Ch";
         }
         if (b.Equals ("2chronicles") || b.Equals ("2chron") || b.Equals ("2ch") || b.Equals ("iich") || b.Equals ("iichr") || b.Equals ("2chr") || b.Equals ("iichron") || b.Equals ("iichronicles") || b.Equals ("2ndchronicles") || b.Equals ("secondchronicles"))
         {
            return (fullName) ? "2 Chronicles" : "2Ch";
         }
         if (b.Equals ("ezra") || b.Equals ("ezr"))
         {
            return "Ezra";
         }
         if (b.Equals ("nehemiah") || b.Equals ("neh") || b.Equals ("ne"))
         {
            return (fullName) ? "Nehemiah" : "Neh";
         }
         if (b.Equals ("esther") || b.Equals ("esth") || b.Equals ("es"))
         {
            return (fullName) ? "Esther" : "Est";
         }
         if (b.Equals ("job") || b.Equals ("jb"))
         {
            return "Job";
         }
         if (b.Equals ("psalm") || b.Equals ("pslm") || b.Equals ("ps") || b.Equals ("psalms") || b.Equals ("psa") || b.Equals ("psm") || b.Equals ("pss"))
         {
            return (fullName) ? "Psalms" : "Ps";
         }
         if (b.Equals ("proverbs") || b.Equals ("prov") || b.Equals ("pr") || b.Equals ("prv") || b.Equals ("pro"))
         {
            return (fullName) ? "Proverbs" : "Pro";
         }
         if (b.Equals ("ecclesiastes") || b.Equals ("eccles") || b.Equals ("ec") || b.Equals ("qoh") || b.Equals ("qoheleth") || b.Equals ("ecc") || b.Equals ("eccl"))
         {
            return (fullName) ? "Ecclesiastes" : "Ecc";
         }
         if (b.Equals ("songofsolomon") || b.Equals ("song") || b.Equals ("so") || b.Equals ("canticleofcanticles") || b.Equals ("canticles") || b.Equals ("songofsongs") || b.Equals ("sos"))
         {
            return (fullName) ? "Song of Solomon" : "Sos";
         }
         if (b.Equals ("isaiah") || b.Equals ("isa") || b.Equals ("is"))
         {
            return (fullName) ? "Isaiah" : "Isa";
         }
         if (b.Equals ("jeremiah") || b.Equals ("jer") || b.Equals ("je") || b.Equals ("jr"))
         {
            return (fullName) ? "Jeremiah" : "Jer";
         }
         if (b.Equals ("lamentations") || b.Equals ("lam") || b.Equals ("la"))
         {
            return (fullName) ? "Lamentations" : "Lam";
         }
         if (b.Equals ("ezekiel") || b.Equals ("ezek") || b.Equals ("eze") || b.Equals ("ezk"))
         {
            return (fullName) ? "Ezekiel" : "Eze";
         }
         if (b.Equals ("daniel") || b.Equals ("dan") || b.Equals ("da") || b.Equals ("dn"))
         {
            return (fullName) ? "Daniel" : "Dan";
         }
         if (b.Equals ("hosea") || b.Equals ("hos") || b.Equals ("ho"))
         {
            return (fullName) ? "Hosea" : "Hos";
         }
         if (b.Equals ("joel") || b.Equals ("joe") || b.Equals ("jl"))
         {
            return "Joel";
         }
         if (b.Equals ("amos") || b.Equals ("am") || b.Equals ("amo"))
         {
            return "Amos";
         }
         if (b.Equals ("obadiah") || b.Equals ("obad") || b.Equals ("ob") || b.Equals ("obd") || b.Equals ("oba"))
         {
            return (fullName) ? "Obadiah" : "Oba";
         }
         if (b.Equals ("jonah") || b.Equals ("jnh") || b.Equals ("jon"))
         {
            return (fullName) ? "Jonah" : "Jon";
         }
         if (b.Equals ("micah") || b.Equals ("mic"))
         {
            return (fullName) ? "Micah" : "Mic";
         }
         if (b.Equals ("nahum") || b.Equals ("nah") || b.Equals ("na"))
         {
            return (fullName) ? "Nahum" : "Nah";
         }
         if (b.Equals ("habakkuk") || b.Equals ("hab"))
         {
            return (fullName) ? "Habakkuk" : "Hab";
         }
         if (b.Equals ("zephaniah") || b.Equals ("zeph") || b.Equals ("zep") || b.Equals ("zp"))
         {
            return (fullName) ? "Zephaniah" : "Zep";
         }
         if (b.Equals ("haggai") || b.Equals ("hag") || b.Equals ("hg"))
         {
            return (fullName) ? "Haggai" : "Hag";
         }
         if (b.Equals ("zechariah") || b.Equals ("zech") || b.Equals ("zec") || b.Equals ("zc"))
         {
            return (fullName) ? "Zechariah" : "Zec";
         }
         if (b.Equals ("malachi") || b.Equals ("mal") || b.Equals ("ml"))
         {
            return (fullName) ? "Malachi" : "Mal";
         }
         if (b.Equals ("tobit") || b.Equals ("tob") || b.Equals ("tb"))
         {
            return "Tobit";
         }
         if (b.Equals ("judith") || b.Equals ("jdth") || b.Equals ("jdt") || b.Equals ("jth"))
         {
            return "Judith";
         }
         if (b.Equals ("additionstoesther") || b.Equals ("addesth") || b.Equals ("addes") || b.Equals ("restofesther") || b.Equals ("therestofesther") || b.Equals ("aes"))
         {
            return "Additions to Esther";
         }
         if (b.Equals ("wisdomofsolomon") || b.Equals ("wisdofsol") || b.Equals ("wis") || b.Equals ("ws") || b.Equals ("wisdom"))
         {
            return "Wisdom of Solomon";
         }
         if (b.Equals ("sirach") || b.Equals ("sir") || b.Equals ("ecclesiasticus") || b.Equals ("ecclus"))
         {
            return "Sirach";
         }
         if (b.Equals ("baruch") || b.Equals ("bar"))
         {
            return "Baruch";
         }
         if (b.Equals ("letterofjeremiah") || b.Equals ("letjer") || b.Equals ("lje") || b.Equals ("ltrjer"))
         {
            return "Letter of Jeremiah";
         }
         if (b.Equals ("songofthreeyouths") || b.Equals ("songofthree") || b.Equals ("songthr") || b.Equals ("thesongofthreeyouths") || b.Equals ("praz") || b.Equals ("prayerofazariah") || b.Equals ("azariah") || b.Equals ("thesongofthethreeholychildren") || b.Equals ("thesongofthreejews") || b.Equals ("songofthethreeholychildren") || b.Equals ("songofthr") || b.Equals ("songofthreechildren") || b.Equals ("songofthreejews"))
         {
            return "Song of Three Youths";
         }
         if (b.Equals ("susanna") || b.Equals ("sus"))
         {
            return "Susanna";
         }
         if (b.Equals ("belandthedragon") || b.Equals ("bel"))
         {
            return (fullName) ? "Bel and the Dragon" : "Bel";
         }
         if (b.Equals ("1maccabees") || b.Equals ("1macc") || b.Equals ("1mac") || b.Equals ("1m") || b.Equals ("ima") || b.Equals ("1ma") || b.Equals ("imac") || b.Equals ("imacc") || b.Equals ("imaccabees") || b.Equals ("1stmaccabees") || b.Equals ("firstmaccabees"))
         {
            return "1 Maccabees";
         }
         if (b.Equals ("2maccabees") || b.Equals ("2macc") || b.Equals ("2mac") || b.Equals ("2m") || b.Equals ("iima") || b.Equals ("2ma") || b.Equals ("iimac") || b.Equals ("iimacc") || b.Equals ("iimaccabees") || b.Equals ("2ndmaccabees") || b.Equals ("secondmaccabees"))
         {
            return "2 Maccabees";
         }
         if (b.Equals ("1esdras") || b.Equals ("1esdr") || b.Equals ("1esd") || b.Equals ("ies") || b.Equals ("1es") || b.Equals ("iesd") || b.Equals ("iesdr") || b.Equals ("iesdras") || b.Equals ("1stesdras") || b.Equals ("firstesdras"))
         {
            return "1 Esdras";
         }
         if (b.Equals ("prayerofmanasseh") || b.Equals ("profman") || b.Equals ("prman") || b.Equals ("pma") || b.Equals ("prayerofmanasses"))
         {
            return "Prayer of Manasseh";
         }
         if (b.Equals ("additionalpsalm") || b.Equals ("addpsalm") || b.Equals ("addps"))
         {
            return "Additional Psalm";
         }
         if (b.Equals ("3maccabees") || b.Equals ("3macc") || b.Equals ("3mac") || b.Equals ("iiima") || b.Equals ("3ma") || b.Equals ("iiimac") || b.Equals ("iiimacc") || b.Equals ("iiimaccabees") || b.Equals ("3rdmaccabees") || b.Equals ("thirdmaccabees"))
         {
            return "3 Maccabees";
         }
         if (b.Equals ("2esdras") || b.Equals ("2esdr") || b.Equals ("2esd") || b.Equals ("iies") || b.Equals ("2es") || b.Equals ("iiesd") || b.Equals ("iiesdr") || b.Equals ("iiesdras") || b.Equals ("2ndesdras") || b.Equals ("secondesdras"))
         {
            return "2 Esdras";
         }
         if (b.Equals ("4maccabees") || b.Equals ("4macc") || b.Equals ("4mac") || b.Equals ("ivma") || b.Equals ("4ma") || b.Equals ("ivmac") || b.Equals ("ivmacc") || b.Equals ("ivmaccabees") || b.Equals ("iiiimaccabees") || b.Equals ("4thmaccabees") || b.Equals ("fourthmaccabees"))
         {
            return "4 Maccabees";
         }
         if (b.Equals ("ode"))
         {
            return "Ode";
         }
         if (b.Equals ("psalmsofsolomon") || b.Equals ("pssolomon") || b.Equals ("pssol") || b.Equals ("psalmssolomon"))
         {
            return "Psalms of Solomon";
         }
         if (b.Equals ("epistletothelaodiceans") || b.Equals ("laodiceans") || b.Equals ("laod") || b.Equals ("eplaod") || b.Equals ("epistlaodiceans") || b.Equals ("epistlelaodiceans") || b.Equals ("epistletolaodiceans"))
         {
            return "Epistle to the Laodiceans";
         }
         if (b.Equals ("matthew") || b.Equals ("matt") || b.Equals ("mt") || b.Equals ("mat"))
         {
            return (fullName) ? "Matthew" : "Mat";
         }
         if (b.Equals ("mark") || b.Equals ("mrk") || b.Equals ("mk") || b.Equals ("mr") || b.Equals ("mar"))
         {
            return "Mark";
         }
         if (b.Equals ("luke") || b.Equals ("luk") || b.Equals ("lk") || b.Equals ("lu"))
         {
            return "Luke";
         }
         if (b.Equals ("john") || b.Equals ("jn") || b.Equals ("jhn") || b.Equals ("joh"))
         {
            return "John";
         }
         if (b.Equals ("acts") || b.Equals ("ac") || b.Equals ("act"))
         {
            return "Acts";
         }
         if (b.Equals ("romans") || b.Equals ("rom") || b.Equals ("ro") || b.Equals ("rm"))
         {
            return (fullName) ? "Romans" : "Rom";
         }
         if (b.Equals ("1corinthians") || b.Equals ("1cor") || b.Equals ("1co") || b.Equals ("ico") || b.Equals ("icor") || b.Equals ("icorinthians") || b.Equals ("1stcorinthians") || b.Equals ("firstcorinthians"))
         {
            return (fullName) ? "1 Corinthians" : "1Cor";
         }
         if (b.Equals ("2corinthians") || b.Equals ("2cor") || b.Equals ("2co") || b.Equals ("iico") || b.Equals ("iicor") || b.Equals ("iicorinthians") || b.Equals ("2ndcorinthians") || b.Equals ("secondcorinthians"))
         {
            return (fullName) ? "2 Corinthians" : "2Cor";
         }
         if (b.Equals ("galatians") || b.Equals ("gal") || b.Equals ("ga"))
         {
            return (fullName) ? "Galatians" : "Gal";
         }
         if (b.Equals ("ephesians") || b.Equals ("ephes") || b.Equals ("eph"))
         {
            return (fullName) ? "Ephesians" : "Eph";
         }
         if (b.Equals ("philippians") || b.Equals ("phil") || b.Equals ("php") || b.Equals ("phili"))
         {
            return (fullName) ? "Philippians" : "Php";
         }
         if (b.Equals ("colossians") || b.Equals ("col"))
         {
            return (fullName) ? "Colossians" : "Col";
         }
         if (b.Equals ("1thessalonians") || b.Equals ("1thess") || b.Equals ("1th") || b.Equals ("ith") || b.Equals ("ithes") || b.Equals ("1thes") || b.Equals ("ithess") || b.Equals ("ithessalonians") || b.Equals ("1stthessalonians") || b.Equals ("firstthessalonians"))
         {
            return (fullName) ? "1 Thessalonians" : "1Th";
         }
         if (b.Equals ("2thessalonians") || b.Equals ("2thess") || b.Equals ("2th") || b.Equals ("iith") || b.Equals ("iithes") || b.Equals ("2thes") || b.Equals ("iithess") || b.Equals ("iithessalonians") || b.Equals ("2ndthessalonians") || b.Equals ("secondthessalonians"))
         {
            return (fullName) ? "2 Thessalonians" : "2Th";
         }
         if (b.Equals ("1timothy") || b.Equals ("1tim") || b.Equals ("1ti") || b.Equals ("iti") || b.Equals ("itim") || b.Equals ("itimothy") || b.Equals ("1sttimothy") || b.Equals ("firsttimothy"))
         {
            return (fullName) ? "1 Timothy" : "1Tim";
         }
         if (b.Equals ("2timothy") || b.Equals ("2tim") || b.Equals ("2ti") || b.Equals ("iiti") || b.Equals ("iitim") || b.Equals ("iitimothy") || b.Equals ("2ndtimothy") || b.Equals ("secondtimothy"))
         {
            return (fullName) ? "2 Timothy" : "2Tim";
         }
         if (b.Equals ("titus") || b.Equals ("tit"))
         {
            return (fullName) ? "Titus" : "Tit";
         }
         if (b.Equals ("philemon") || b.Equals ("philem") || b.Equals ("phm"))
         {
            return (fullName) ? "Philemon" : "Phm";
         }
         if (b.Equals ("hebrews") || b.Equals ("heb"))
         {
            return (fullName) ? "Hebrews" : "Heb";
         }
         if (b.Equals ("james") || b.Equals ("jas") || b.Equals ("jm") || b.Equals ("jam"))
         {
            return (fullName) ? "James" : "Jam";
         }
         if (b.Equals ("1peter") || b.Equals ("1pet") || b.Equals ("1pe") || b.Equals ("ipe") || b.Equals ("ipet") || b.Equals ("ipt") || b.Equals ("1pt") || b.Equals ("ipeter") || b.Equals ("1stpeter") || b.Equals ("firstpeter"))
         {
            return (fullName) ? "1 Peter" : "1Pet";
         }
         if (b.Equals ("2peter") || b.Equals ("2pet") || b.Equals ("2pe") || b.Equals ("iipe") || b.Equals ("iipet") || b.Equals ("iipt") || b.Equals ("2pt") || b.Equals ("iipeter") || b.Equals ("2ndpeter") || b.Equals ("secondpeter"))
         {
            return (fullName) ? "2 Peter" : "2Pet";
         }
         if (b.Equals ("1john") || b.Equals ("1jn") || b.Equals ("ijn") || b.Equals ("ijo") || b.Equals ("1jo") || b.Equals ("ijoh") || b.Equals ("1joh") || b.Equals ("ijhn") || b.Equals ("1jhn") || b.Equals ("ijohn") || b.Equals ("1stjohn") || b.Equals ("firstjohn"))
         {
            return (fullName) ? "1 John" : "1Jo";
         }
         if (b.Equals ("2john") || b.Equals ("2jn") || b.Equals ("iijn") || b.Equals ("iijo") || b.Equals ("2jo") || b.Equals ("iijoh") || b.Equals ("2joh") || b.Equals ("iijhn") || b.Equals ("2jhn") || b.Equals ("iijohn") || b.Equals ("2ndjohn") || b.Equals ("secondjohn"))
         {
            return (fullName) ? "2 John" : "2Jo";
         }
         if (b.Equals ("3john") || b.Equals ("3jn") || b.Equals ("iiijn") || b.Equals ("iiijo") || b.Equals ("3jo") || b.Equals ("iiijoh") || b.Equals ("3joh") || b.Equals ("iiijhn") || b.Equals ("3jhn") || b.Equals ("iiijohn") || b.Equals ("3rdjohn") || b.Equals ("thirdjohn"))
         {
            return (fullName) ? "3 John" : "3Jo";
         }
         if (b.Equals ("jude") || b.Equals ("jud"))
         {
            return "Jude";
         }
         if (b.Equals ("revelation") || b.Equals ("rev") || b.Equals ("re") || b.Equals ("therevelation"))
         {
            return (fullName) ? "Revelation" : "Rev";
         }

         return GetOtherBook (b, fullName);
      }

      /// <summary>
      /// Gets the name of the book for the give string...
      /// </summary>
      /// <param name="book">Book String.</param>
      /// <param name="fullName">True if you want the full name, false if you want the abbrevation.</param>
      /// <returns>Name or Abbreviation of Book</returns>
      public static string GetOtherBook (string book, bool fullName)
      {
         foreach (KeyValuePair<string, string> kvp in FrmMain.OtherTexts)
         {
            string val = kvp.Key.Replace (" ", "");
            if (book.Equals (val, StringComparison.CurrentCultureIgnoreCase))
               return (fullName) ? kvp.Key : kvp.Value;
         }

         return null;
      }

      /// <summary>
      /// Check to see if the book is from the new testament...
      /// </summary>
      /// <param name="b">Book to look for.</param>
      /// <returns>True if book is in New Testament, otherwise false.</returns>
      public static bool IsBookNewTestament (string b)
      {
         b = b.ToLower ();
         if (b.Equals ("matthew") || b.Equals ("matt") || b.Equals ("mt") || b.Equals ("mat"))
         {
            return true;
         }
         if (b.Equals ("mark") || b.Equals ("mrk") || b.Equals ("mk") || b.Equals ("mr"))
         {
            return true;
         }
         if (b.Equals ("luke") || b.Equals ("luk") || b.Equals ("lk"))
         {
            return true;
         }
         if (b.Equals ("john") || b.Equals ("jn") || b.Equals ("jhn") || b.Equals ("joh"))
         {
            return true;
         }
         if (b.Equals ("acts") || b.Equals ("ac") || b.Equals ("act"))
         {
            return true;
         }
         if (b.Equals ("romans") || b.Equals ("rom") || b.Equals ("ro") || b.Equals ("rm"))
         {
            return true;
         }
         if (b.Equals ("1corinthians") || b.Equals ("1cor") || b.Equals ("1co") || b.Equals ("ico") || b.Equals ("icor") || b.Equals ("icorinthians") || b.Equals ("1stcorinthians") || b.Equals ("firstcorinthians"))
         {
            return true;
         }
         if (b.Equals ("2corinthians") || b.Equals ("2cor") || b.Equals ("2co") || b.Equals ("iico") || b.Equals ("iicor") || b.Equals ("iicorinthians") || b.Equals ("2ndcorinthians") || b.Equals ("secondcorinthians"))
         {
            return true;
         }
         if (b.Equals ("galatians") || b.Equals ("gal") || b.Equals ("ga"))
         {
            return true;
         }
         if (b.Equals ("ephesians") || b.Equals ("ephes") || b.Equals ("eph"))
         {
            return true;
         }
         if (b.Equals ("philippians") || b.Equals ("phil") || b.Equals ("php") || b.Equals ("phili"))
         {
            return true;
         }
         if (b.Equals ("colossians") || b.Equals ("col"))
         {
            return true;
         }
         if (b.Equals ("1thessalonians") || b.Equals ("1thess") || b.Equals ("1th") || b.Equals ("ith") || b.Equals ("ithes") || b.Equals ("1thes") || b.Equals ("ithess") || b.Equals ("ithessalonians") || b.Equals ("1stthessalonians") || b.Equals ("firstthessalonians"))
         {
            return true;
         }
         if (b.Equals ("2thessalonians") || b.Equals ("2thess") || b.Equals ("2th") || b.Equals ("iith") || b.Equals ("iithes") || b.Equals ("2thes") || b.Equals ("iithess") || b.Equals ("iithessalonians") || b.Equals ("2ndthessalonians") || b.Equals ("secondthessalonians"))
         {
            return true;
         }
         if (b.Equals ("1timothy") || b.Equals ("1tim") || b.Equals ("1ti") || b.Equals ("iti") || b.Equals ("itim") || b.Equals ("itimothy") || b.Equals ("1sttimothy") || b.Equals ("firsttimothy"))
         {
            return true;
         }
         if (b.Equals ("2timothy") || b.Equals ("2tim") || b.Equals ("2ti") || b.Equals ("iiti") || b.Equals ("iitim") || b.Equals ("iitimothy") || b.Equals ("2ndtimothy") || b.Equals ("secondtimothy"))
         {
            return true;
         }
         if (b.Equals ("titus") || b.Equals ("tit"))
         {
            return true;
         }
         if (b.Equals ("philemon") || b.Equals ("philem") || b.Equals ("phm"))
         {
            return true;
         }
         if (b.Equals ("hebrews") || b.Equals ("heb"))
         {
            return true;
         }
         if (b.Equals ("james") || b.Equals ("jas") || b.Equals ("jm") || b.Equals ("jam"))
         {
            return true;
         }
         if (b.Equals ("1peter") || b.Equals ("1pet") || b.Equals ("1pe") || b.Equals ("ipe") || b.Equals ("ipet") || b.Equals ("ipt") || b.Equals ("1pt") || b.Equals ("ipeter") || b.Equals ("1stpeter") || b.Equals ("firstpeter"))
         {
            return true;
         }
         if (b.Equals ("2peter") || b.Equals ("2pet") || b.Equals ("2pe") || b.Equals ("iipe") || b.Equals ("iipet") || b.Equals ("iipt") || b.Equals ("2pt") || b.Equals ("iipeter") || b.Equals ("2ndpeter") || b.Equals ("secondpeter"))
         {
            return true;
         }
         if (b.Equals ("1john") || b.Equals ("1jn") || b.Equals ("ijn") || b.Equals ("ijo") || b.Equals ("1jo") || b.Equals ("ijoh") || b.Equals ("1joh") || b.Equals ("ijhn") || b.Equals ("1jhn") || b.Equals ("ijohn") || b.Equals ("1stjohn") || b.Equals ("firstjohn"))
         {
            return true;
         }
         if (b.Equals ("2john") || b.Equals ("2jn") || b.Equals ("iijn") || b.Equals ("iijo") || b.Equals ("2jo") || b.Equals ("iijoh") || b.Equals ("2joh") || b.Equals ("iijhn") || b.Equals ("2jhn") || b.Equals ("iijohn") || b.Equals ("2ndjohn") || b.Equals ("secondjohn"))
         {
            return true;
         }
         if (b.Equals ("3john") || b.Equals ("3jn") || b.Equals ("iiijn") || b.Equals ("iiijo") || b.Equals ("3jo") || b.Equals ("iiijoh") || b.Equals ("3joh") || b.Equals ("iiijhn") || b.Equals ("3jhn") || b.Equals ("iiijohn") || b.Equals ("3rdjohn") || b.Equals ("thirdjohn"))
         {
            return true;
         }
         if (b.Equals ("jude") || b.Equals ("jud"))
         {
            return true;
         }
         if (b.Equals ("revelation") || b.Equals ("rev") || b.Equals ("re") || b.Equals ("therevelation"))
         {
            return true;
         }

         return false;
      }
   }
}
